package org.game.db.bean;

import org.game.db.cache.CurrentScriptRecordCache;
import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import org.apache.commons.lang3.ArrayUtils;
import com.sojoys.artifact.build.data.base.BasePojo;
import java.util.List;
import java.sql.SQLException;
import static org.game.db.StaticResource.CurrentScriptRecordResource.*;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.tools.SK_Plus;
import com.sojoys.artifact.tools.ToolCopy;
import org.game.db.cache.PlayerCache;
import java.sql.ResultSet;
import java.util.Map;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.alibaba.fastjson.JSONObject;
import com.sojoys.artifact.constant.DataModelKeyEnum;
import static org.game.db.StaticResource.CurrentScriptRecordResource.*;
/**
 * 当前剧本记录
 */
public class CurrentScriptRecord extends BasePojo<CurrentScriptRecord> {
	
	
	/**
	 * 索引值
	 */
	private String[] indexValues = new String[2];
	
	/**
	* id
	*/
	private long id;
	
	/**
	* create_date
	*/
	private java.util.Date createDate;
	
	/**
	* modified_date
	*/
	private java.util.Date modifiedDate;
	
	/**
	* 本次剧本已经获得的奖励
	*/
	private Map reward;
	
	/**
	* 对话次数记录
	*/
	private Map dialogueCount;
	
	/**
	* 约会类型
	*/
	private int datingType;
	
	/**
	* 积分
	*/
	private int score;
	
	/**
	* 好感度奖励
	*/
	private int favorReward;
	
	/**
	* 当前节点cid
	*/
	private int currentCid;
	
	/**
	* 剧本分支节点
	*/
	private Map currentScript;
	
	/**
	* 剧本id
	*/
	private int scriptId;
	
	/**
	* 被选择的节点
	*/
	private List selectedNode;
	
	/**
	* 玩家id
	*/
	private int playerId;
	
	/**
	* 看板娘id
	*/
	private List roleIds;
	
	
	@Deprecated
	public static CurrentScriptRecord builder() {
		CurrentScriptRecord currentScriptRecord = new CurrentScriptRecord();
		return currentScriptRecord;
	}
	
	@Deprecated
	public CurrentScriptRecord() {
		super();
	}
	
	public CurrentScriptRecord(long id, Map reward, Map dialogueCount, int datingType, int score, int favorReward, int currentCid, Map currentScript, int scriptId, List selectedNode, int playerId, List roleIds) {
		super();
		this.id = id;
		this.createDate = new java.util.Date();
		this.modifiedDate = new java.util.Date();
		this.reward = reward;
		this.dialogueCount = dialogueCount;
		this.datingType = datingType;
		this.score = score;
		this.favorReward = favorReward;
		this.currentCid = currentCid;
		this.currentScript = currentScript;
		this.scriptId = scriptId;
		this.selectedNode = selectedNode;
		this.playerId = playerId;
		this.roleIds = roleIds;
	}
	
	/**
	 * id
	 */
	public long getId() {return id;}
	
	/**
	 * id
	 */
	public CurrentScriptRecord setId(long id) {this.id = id;return this;}
	
	/**
	 * create_date
	 */
	public java.util.Date getCreateDate() {return createDate;}
	
	/**
	 * create_date
	 */
	protected CurrentScriptRecord setCreateDate(java.util.Date createDate) {this.createDate = createDate;return this;}
	
	/**
	 * modified_date
	 */
	public java.util.Date getModifiedDate() {return modifiedDate;}
	
	/**
	 * modified_date
	 */
	protected CurrentScriptRecord setModifiedDate(java.util.Date modifiedDate) {this.modifiedDate = modifiedDate;return this;}
	
	/**
	 * 本次剧本已经获得的奖励
	 */
	public Map getReward() {return reward;}
	
	/**
	 * 本次剧本已经获得的奖励
	 */
	public CurrentScriptRecord setReward(Map reward) {this.reward = reward;return this;}
	
	/**
	 * 本次剧本已经获得的奖励
	 */
	public byte[] getRewardByte() {
		return toBytes(reward);
	}
	
	/**
	 * 本次剧本已经获得的奖励
	 */
	public Map initRewardByte(byte[] _byte) {
		return (Map)forBytesObject(_byte);
	}	
	/**
	 * 对话次数记录
	 */
	public Map getDialogueCount() {return dialogueCount;}
	
	/**
	 * 对话次数记录
	 */
	public CurrentScriptRecord setDialogueCount(Map dialogueCount) {this.dialogueCount = dialogueCount;return this;}
	
	/**
	 * 对话次数记录
	 */
	public byte[] getDialogueCountByte() {
		return toBytes(dialogueCount);
	}
	
	/**
	 * 对话次数记录
	 */
	public Map initDialogueCountByte(byte[] _byte) {
		return (Map)forBytesObject(_byte);
	}	
	/**
	 * 约会类型
	 */
	public int getDatingType() {return datingType;}
	
	/**
	 * 约会类型
	 */
	public CurrentScriptRecord setDatingType(int datingType) {this.datingType = datingType;return this;}
	
	/**
	 * 积分
	 */
	public int getScore() {return score;}
	
	/**
	 * 积分
	 */
	public CurrentScriptRecord setScore(int score) {this.score = score;return this;}
	
	/**
	 * 好感度奖励
	 */
	public int getFavorReward() {return favorReward;}
	
	/**
	 * 好感度奖励
	 */
	public CurrentScriptRecord setFavorReward(int favorReward) {this.favorReward = favorReward;return this;}
	
	/**
	 * 当前节点cid
	 */
	public int getCurrentCid() {return currentCid;}
	
	/**
	 * 当前节点cid
	 */
	public CurrentScriptRecord setCurrentCid(int currentCid) {this.currentCid = currentCid;return this;}
	
	/**
	 * 剧本分支节点
	 */
	public Map getCurrentScript() {return currentScript;}
	
	/**
	 * 剧本分支节点
	 */
	public CurrentScriptRecord setCurrentScript(Map currentScript) {this.currentScript = currentScript;return this;}
	
	/**
	 * 剧本分支节点
	 */
	public byte[] getCurrentScriptByte() {
		return toBytes(currentScript);
	}
	
	/**
	 * 剧本分支节点
	 */
	public Map initCurrentScriptByte(byte[] _byte) {
		return (Map)forBytesObject(_byte);
	}	
	/**
	 * 剧本id
	 */
	public int getScriptId() {return scriptId;}
	
	/**
	 * 剧本id
	 */
	public CurrentScriptRecord setScriptId(int scriptId) {this.scriptId = scriptId;return this;}
	
	/**
	 * 被选择的节点
	 */
	public List getSelectedNode() {return selectedNode;}
	
	/**
	 * 被选择的节点
	 */
	public CurrentScriptRecord setSelectedNode(List selectedNode) {this.selectedNode = selectedNode;return this;}
	
	/**
	 * 被选择的节点
	 */
	public byte[] getSelectedNodeByte() {
		return toBytes(selectedNode);
	}
	
	/**
	 * 被选择的节点
	 */
	public List initSelectedNodeByte(byte[] _byte) {
		return (List)forBytesObject(_byte);
	}	
	/**
	 * 玩家id
	 */
	public int getPlayerId() {return playerId;}
	
	/**
	 * 玩家id
	 */
	public CurrentScriptRecord setPlayerId(int playerId) {this.playerId = playerId;return this;}
	
	/**
	 * 看板娘id
	 */
	public List getRoleIds() {return roleIds;}
	
	/**
	 * 看板娘id
	 */
	public CurrentScriptRecord setRoleIds(List roleIds) {this.roleIds = roleIds;return this;}
	
	/**
	 * 看板娘id
	 */
	public byte[] getRoleIdsByte() {
		return toBytes(roleIds);
	}
	
	/**
	 * 看板娘id
	 */
	public List initRoleIdsByte(byte[] _byte) {
		return (List)forBytesObject(_byte);
	}	
	
	// 代理
	private org.game.db.proxy.bean.CurrentScriptRecordProxy currentScriptRecordProxy = new org.game.db.proxy.bean.CurrentScriptRecordProxy().build(this);
	
	public org.game.db.proxy.bean.CurrentScriptRecordProxy getCurrentScriptRecordProxy(){return currentScriptRecordProxy;}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected Object[] getFKTableNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return FK_SOURCE_TABLE_NAMES;
		case PINGYING:
			return FK_PINGYING_TABLE_NAMES;
		case HASHCODE:
			return FK_HASHCODE_TABLE_NAMES;
		default:
			return FK_PINGYING_TABLE_NAMES;
		}
	}
	
	protected Object[] getFKColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return FK_SOURCE_COLUMN_NAMES;
		case PINGYING:
			return FK_PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return FK_HASHCODE_COLUMN_NAMES;
		default:
			return FK_PINGYING_TABLE_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected String[] getColumnTypes(){
		return COLUMN_COLUMNTYPES;
	}
	
	protected int getColumnCount(){
		return COLUMN_COUNT;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.createDate;
        values[2] = this.modifiedDate;
        values[3] = this.reward;
        values[4] = this.dialogueCount;
        values[5] = this.datingType;
        values[6] = this.score;
        values[7] = this.favorReward;
        values[8] = this.currentCid;
        values[9] = this.currentScript;
        values[10] = this.scriptId;
        values[11] = this.selectedNode;
        values[12] = this.playerId;
        values[13] = this.roleIds;
        return values;
	}
	
	public CurrentScriptRecord deepCopy(){
		CurrentScriptRecord currentScriptRecord = null;
		try {
			currentScriptRecord = (CurrentScriptRecord) super.clone();
		    currentScriptRecord.setCreateDate(ToolCopy.copyObject(this.createDate));
		    currentScriptRecord.setModifiedDate(ToolCopy.copyObject(this.modifiedDate));
		    currentScriptRecord.setReward(ToolCopy.copyObject(this.reward));
		    currentScriptRecord.setDialogueCount(ToolCopy.copyObject(this.dialogueCount));
		    currentScriptRecord.setCurrentScript(ToolCopy.copyObject(this.currentScript));
		    currentScriptRecord.setSelectedNode(ToolCopy.copyObject(this.selectedNode));
		    currentScriptRecord.setRoleIds(ToolCopy.copyObject(this.roleIds));
		    // 克隆索引
		    currentScriptRecord.indexValues = ArrayUtils.clone(indexValues);
			return currentScriptRecord;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return currentScriptRecord;
	}
	
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.createDate);
        map.put(keys[2], this.modifiedDate);
        map.put(keys[3], this.reward);
        map.put(keys[4], this.dialogueCount);
        map.put(keys[5], this.datingType);
        map.put(keys[6], this.score);
        map.put(keys[7], this.favorReward);
        map.put(keys[8], this.currentCid);
        map.put(keys[9], this.currentScript);
        map.put(keys[10], this.scriptId);
        map.put(keys[11], this.selectedNode);
        map.put(keys[12], this.playerId);
        map.put(keys[13], this.roleIds);
        return map;
    }
    
    protected CurrentScriptRecord createForMap(Object[] keys,Map map){
   		this.id = (long)map.get(keys[0]);
   		this.createDate = (java.util.Date)map.get(keys[1]);
   		this.modifiedDate = (java.util.Date)map.get(keys[2]);
   		this.reward = (Map)map.get(keys[3]);
   		this.dialogueCount = (Map)map.get(keys[4]);
   		this.datingType = (int)map.get(keys[5]);
   		this.score = (int)map.get(keys[6]);
   		this.favorReward = (int)map.get(keys[7]);
   		this.currentCid = (int)map.get(keys[8]);
   		this.currentScript = (Map)map.get(keys[9]);
   		this.scriptId = (int)map.get(keys[10]);
   		this.selectedNode = (List)map.get(keys[11]);
   		this.playerId = (int)map.get(keys[12]);
   		this.roleIds = (List)map.get(keys[13]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.createDate);
        obj.put(keys[2], this.modifiedDate);
        obj.put(keys[3], toBytes(reward));
        obj.put(keys[4], toBytes(dialogueCount));
        obj.put(keys[5], this.datingType);
        obj.put(keys[6], this.score);
        obj.put(keys[7], this.favorReward);
        obj.put(keys[8], this.currentCid);
        obj.put(keys[9], toBytes(currentScript));
        obj.put(keys[10], this.scriptId);
        obj.put(keys[11], toBytes(selectedNode));
        obj.put(keys[12], this.playerId);
        obj.put(keys[13], toBytes(roleIds));
        return obj;
    }
    
    protected CurrentScriptRecord createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getLongValue(keys[0]);
	    this.createDate = obj.getDate(keys[1]);
	    this.modifiedDate = obj.getDate(keys[2]);
		this.reward = (Map)forBytesObject(obj.getBytes(keys[3]));
		this.dialogueCount = (Map)forBytesObject(obj.getBytes(keys[4]));
	    this.datingType = obj.getIntValue(keys[5]);
	    this.score = obj.getIntValue(keys[6]);
	    this.favorReward = obj.getIntValue(keys[7]);
	    this.currentCid = obj.getIntValue(keys[8]);
		this.currentScript = (Map)forBytesObject(obj.getBytes(keys[9]));
	    this.scriptId = obj.getIntValue(keys[10]);
		this.selectedNode = (List)forBytesObject(obj.getBytes(keys[11]));
	    this.playerId = obj.getIntValue(keys[12]);
		this.roleIds = (List)forBytesObject(obj.getBytes(keys[13]));
        return this;
    }
    
    
    public CurrentScriptRecord createForResultSet(ResultSet rs) throws SQLException{
	    this.id = rs.getLong(SOURCE_COLUMN_NAMES[0]);
	    this.createDate = rs.getTimestamp(SOURCE_COLUMN_NAMES[1]);
	    this.modifiedDate = rs.getTimestamp(SOURCE_COLUMN_NAMES[2]);
		this.reward = (Map)forBytesObject(rs.getBytes(SOURCE_COLUMN_NAMES[3]));
		this.dialogueCount = (Map)forBytesObject(rs.getBytes(SOURCE_COLUMN_NAMES[4]));
	    this.datingType = rs.getInt(SOURCE_COLUMN_NAMES[5]);
	    this.score = rs.getInt(SOURCE_COLUMN_NAMES[6]);
	    this.favorReward = rs.getInt(SOURCE_COLUMN_NAMES[7]);
	    this.currentCid = rs.getInt(SOURCE_COLUMN_NAMES[8]);
		this.currentScript = (Map)forBytesObject(rs.getBytes(SOURCE_COLUMN_NAMES[9]));
	    this.scriptId = rs.getInt(SOURCE_COLUMN_NAMES[10]);
		this.selectedNode = (List)forBytesObject(rs.getBytes(SOURCE_COLUMN_NAMES[11]));
	    this.playerId = rs.getInt(SOURCE_COLUMN_NAMES[12]);
		this.roleIds = (List)forBytesObject(rs.getBytes(SOURCE_COLUMN_NAMES[13]));
	    return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeLong(this.id);
	    byteBuf.writeDate(this.createDate);
	    byteBuf.writeDate(this.modifiedDate);
	    byteBuf.writeObject(this.reward);
	    byteBuf.writeObject(this.dialogueCount);
	    byteBuf.writeInt(this.datingType);
	    byteBuf.writeInt(this.score);
	    byteBuf.writeInt(this.favorReward);
	    byteBuf.writeInt(this.currentCid);
	    byteBuf.writeObject(this.currentScript);
	    byteBuf.writeInt(this.scriptId);
	    byteBuf.writeObject(this.selectedNode);
	    byteBuf.writeInt(this.playerId);
	    byteBuf.writeObject(this.roleIds);
    }
	
	protected CurrentScriptRecord readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readLong(null);
	    this.createDate = byteBuf.readDate(null);
	    this.modifiedDate = byteBuf.readDate(null);
	    this.reward = (Map)byteBuf.readObject();
	    this.dialogueCount = (Map)byteBuf.readObject();
	    this.datingType = byteBuf.readInt(null);
	    this.score = byteBuf.readInt(null);
	    this.favorReward = byteBuf.readInt(null);
	    this.currentCid = byteBuf.readInt(null);
	    this.currentScript = (Map)byteBuf.readObject();
	    this.scriptId = byteBuf.readInt(null);
	    this.selectedNode = (List)byteBuf.readObject();
	    this.playerId = byteBuf.readInt(null);
	    this.roleIds = (List)byteBuf.readObject();
	    return this;
	}
    
    
    protected JSONObject exportFKTableMap(Object[] keys,JSONObject map,DataModelKeyEnum e){
        return map;
    }
    
    protected boolean importFKTableMap(Object[] keys,JSONObject map,DataModelKeyEnum e){
		return true;
    }
    
	/** 取得[player]*/
	public Player getPlayerPkPlayerId(){
		return PlayerCache.me().getById(playerId);
	}
	
    /** 级联删除(延迟入库) */
    public boolean deleteAndSon(){
    	return false;
    }
    
    /** 级联删除(及时入库) */
    public boolean deleteAndSonAndFlush(){
    	return false;
    }
    
    /** 延迟插入数据库 */
    public CurrentScriptRecord insert(){
    	return CurrentScriptRecordCache.me().insert(this);
    }
    /** 延迟更新数据库 */
    public CurrentScriptRecord update(){
    	return CurrentScriptRecordCache.me().update(this);
    }
    /** 延迟删除数据库 */
    public boolean delete(){
    	return CurrentScriptRecordCache.me().delete(this);
    }
    /** 即时插入数据库 */
    public CurrentScriptRecord insertAndFlush(){
    	return CurrentScriptRecordCache.me().insertAndFlush(this);
    }
    /** 即时更新数据库 */
    public CurrentScriptRecord updateAndFlush(){
    	return CurrentScriptRecordCache.me().updateAndFlush(this);
    }
    /** 即时删除数据库 */
    public boolean deleteAndFlush(){
    	return CurrentScriptRecordCache.me().deleteAndFlush(this);
    }
    
    
	
	/**
	 * 同步索引值
	 */
	public CurrentScriptRecord syncIndexValues(){
		indexValues[0] = SK_Plus.b(getId()).e();
		indexValues[1] = SK_Plus.b(getPlayerId()).e();
		return this;
	}
	/**
	 * 取得索引
	 */
	public String[] getIndexValues(){
		return indexValues;
	}
	
	protected Object getPrimaryKey(){
		return getId();
	}
	
	protected void setPrimaryKey(Object key){
		setId((long)key);
	}
//自定义内容起始位置

	


//自定义内容结束位置
}